package com.bw.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bw.bean.Classes;
import com.bw.bean.Student;
import com.bw.bean.Teachers;
import com.bw.bean.TestReturn;
import com.bw.service.AddService;
import com.bw.service.JobService;

@Controller
public class AddController {
	@Autowired
	private AddService AddServiceImpl;
	
	@RequestMapping("addStudent")
	public ModelAndView add(){
		ModelAndView mav = new ModelAndView("addStudent");
		List<TestReturn> classes = AddServiceImpl.getClasses();
		mav.addObject("classes",classes);
		return mav;
	}
	@RequestMapping("doAddStudent")
	@ResponseBody
	public int doAddStudent(Student student){
		int msg = AddServiceImpl.doAddStudent(student);
		return msg;
	}
	@RequestMapping("addClasses")
	public ModelAndView addClasses(){
		ModelAndView mav = new ModelAndView("addClasses");
		List<TestReturn> teachers = AddServiceImpl.getTeacher();
		mav.addObject("teachers",teachers);
		return mav;
	}
	@RequestMapping("doAddClasses")
	@ResponseBody
	public int doAddClasses(Classes classes){
		int msg = AddServiceImpl.doAddClasses(classes);
		return msg;
	}
	
	@RequestMapping("addTeacher")
	public String jump(){
		return "addTeacher";
	}
	@RequestMapping("doAddTeacher")
	@ResponseBody
	public int doAddTeacher(Teachers teachers){
		int msg = AddServiceImpl.doAddTeachers(teachers);
		return msg;
	}
	
}
